package com.itheima.youdianda.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.youdianda.dto.DictDto;
import com.itheima.youdianda.entity.SysDict;
import com.itheima.youdianda.mapper.SysDictMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.youdianda.service.SysDictService;
import com.itheima.youdianda.util.TestBeanUtiles;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 字典表 服务实现类
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@Service
public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> implements SysDictService {

    @Override
    public  Map<String, Map<String, String>> getDictsList() {
        List<SysDict> list = this.list();
        Map<String,Map<String, Map<String,String>>> map = new HashMap<>();
        Map<String, Map<String, String>> mapMap = new HashMap<>();
        Map<String,String> tbMap = new HashMap<>();
        Map<String,String> iMap = new HashMap<>();
        Map<String,String> oMap = new HashMap<>();
        Map<String,String> tmMap = new HashMap<>();
        for (SysDict sysDict : list) {
            switch (sysDict.getType()) {
                case "table_type":
                    tbMap.put(sysDict.getValue(),sysDict.getLabel());
                    mapMap.put(sysDict.getType(),tbMap);
                    break;
                case "interface_type":

                    iMap.put(sysDict.getValue(),sysDict.getLabel());
                    mapMap.put(sysDict.getType(),iMap);
                    break;
                case "order_type":

                    oMap.put(sysDict.getValue(),sysDict.getLabel());
                    mapMap.put(sysDict.getType(),oMap);
                    break;
                case "report_type":
                    Map<String,String> rMap = new HashMap<>();
                    rMap.put(sysDict.getValue(),sysDict.getLabel());
                    mapMap.put(sysDict.getType(),rMap);
                    break;
                case "theme":
                    tmMap.put(sysDict.getValue(),sysDict.getLabel());
                    mapMap.put(sysDict.getType(),tmMap);
                    break;
                default:
                    break;
            }
        }
        return mapMap;
    }
}
